<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>EasyQtSql: UpdateQuery Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">EasyQtSql
   </div>
   <div id="projectbrief">Easy SQL data access helper for QtSql</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('class_update_query.htm','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="class_update_query-members.htm">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">UpdateQuery Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>QSqlQuery wrapper for <em>UPDATE ... SET ... WHERE ...</em> query execution.  
 <a href="class_update_query.htm#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_easy_qt_sql___update_query_8h_source.htm">EasyQtSql_UpdateQuery.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a2a81be31fd760b73a5cda2182fb347f1"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_update_query.htm#a2a81be31fd760b73a5cda2182fb347f1">UpdateQuery</a> (const QString &amp;table, const QSqlDatabase &amp;db)</td></tr>
<tr class="separator:a2a81be31fd760b73a5cda2182fb347f1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7c1b4eaa45048ec8a3f6f7d4223f5ace"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_update_query.htm">UpdateQuery</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_update_query.htm#a7c1b4eaa45048ec8a3f6f7d4223f5ace">set</a> (const QString &amp;field, const QVariant &amp;value)</td></tr>
<tr class="memdesc:a7c1b4eaa45048ec8a3f6f7d4223f5ace"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets table <em>field</em> to <em>value</em>  <a href="#a7c1b4eaa45048ec8a3f6f7d4223f5ace">More...</a><br /></td></tr>
<tr class="separator:a7c1b4eaa45048ec8a3f6f7d4223f5ace"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab83ea43c6e98bd5534d9fa8ba0e5fe1b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_update_query.htm">UpdateQuery</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_update_query.htm#ab83ea43c6e98bd5534d9fa8ba0e5fe1b">set</a> (const QVariantMap &amp;map)</td></tr>
<tr class="memdesc:ab83ea43c6e98bd5534d9fa8ba0e5fe1b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets table fields to values from <em>map</em>  <a href="#ab83ea43c6e98bd5534d9fa8ba0e5fe1b">More...</a><br /></td></tr>
<tr class="separator:ab83ea43c6e98bd5534d9fa8ba0e5fe1b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abb4c7b7502599a78699e3a1f4cb4cbda"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_non_query_result.htm">NonQueryResult</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_update_query.htm#abb4c7b7502599a78699e3a1f4cb4cbda">where</a> (const QString &amp;expr)</td></tr>
<tr class="memdesc:abb4c7b7502599a78699e3a1f4cb4cbda"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes update query with <em>expr</em> condition.  <a href="#abb4c7b7502599a78699e3a1f4cb4cbda">More...</a><br /></td></tr>
<tr class="separator:abb4c7b7502599a78699e3a1f4cb4cbda"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a666356b92d38bed265199b57bcd8c0e7"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_non_query_result.htm">NonQueryResult</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_update_query.htm#a666356b92d38bed265199b57bcd8c0e7">where</a> (const QString &amp;expr, const QVariant &amp;last)</td></tr>
<tr class="memdesc:a666356b92d38bed265199b57bcd8c0e7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes update query with <em>expr</em> condition and <em>last</em> parameter binding.  <a href="#a666356b92d38bed265199b57bcd8c0e7">More...</a><br /></td></tr>
<tr class="separator:a666356b92d38bed265199b57bcd8c0e7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a423087092ef6c17c5d97e6a268f85775"><td class="memTemplParams" colspan="2">template&lt;typename... Rest&gt; </td></tr>
<tr class="memitem:a423087092ef6c17c5d97e6a268f85775"><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="class_non_query_result.htm">NonQueryResult</a>&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_update_query.htm#a423087092ef6c17c5d97e6a268f85775">where</a> (const QString &amp;expr, const QVariant &amp;first, const Rest &amp;... rest)</td></tr>
<tr class="separator:a423087092ef6c17c5d97e6a268f85775"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa685f7d12dec7214a783be4289b39f4c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_non_query_result.htm">NonQueryResult</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_update_query.htm#aa685f7d12dec7214a783be4289b39f4c">exec</a> ()</td></tr>
<tr class="memdesc:aa685f7d12dec7214a783be4289b39f4c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes UPDATE query without conditions.  <a href="#aa685f7d12dec7214a783be4289b39f4c">More...</a><br /></td></tr>
<tr class="separator:aa685f7d12dec7214a783be4289b39f4c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>QSqlQuery wrapper for <em>UPDATE ... SET ... WHERE ...</em> query execution. </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a2a81be31fd760b73a5cda2182fb347f1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2a81be31fd760b73a5cda2182fb347f1">&#9670;&nbsp;</a></span>UpdateQuery()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">UpdateQuery::UpdateQuery </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>table</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QSqlDatabase &amp;&#160;</td>
          <td class="paramname"><em>db</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="aa685f7d12dec7214a783be4289b39f4c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa685f7d12dec7214a783be4289b39f4c">&#9670;&nbsp;</a></span>exec()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_non_query_result.htm">NonQueryResult</a> UpdateQuery::exec </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Executes UPDATE query without conditions. </p>

</div>
</div>
<a id="a7c1b4eaa45048ec8a3f6f7d4223f5ace"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7c1b4eaa45048ec8a3f6f7d4223f5ace">&#9670;&nbsp;</a></span>set() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_update_query.htm">UpdateQuery</a>&amp; UpdateQuery::set </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>field</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QVariant &amp;&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Sets table <em>field</em> to <em>value</em> </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">field</td><td>Table field name </td></tr>
    <tr><td class="paramname">value</td><td>Value to set </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="class_update_query.htm" title="QSqlQuery wrapper for UPDATE ... SET ... WHERE ... query execution. ">UpdateQuery</a> reference</dd></dl>
<p>The method returns an <a class="el" href="class_update_query.htm" title="QSqlQuery wrapper for UPDATE ... SET ... WHERE ... query execution. ">UpdateQuery</a> reference so its call can be chained:</p>
<div class="fragment"><div class="line"><span class="comment">//UPDATE table SET a=111, b=222</span></div><div class="line">t.<a class="code" href="class_database.htm#a2d8dad3df4134306749582216bd437e0">update</a>(<span class="stringliteral">&quot;table&quot;</span>)</div><div class="line">      .<a class="code" href="class_update_query.htm#a7c1b4eaa45048ec8a3f6f7d4223f5ace">set</a>(<span class="stringliteral">&quot;a&quot;</span>, 111) <span class="comment">//method chaining</span></div><div class="line">      .<a class="code" href="class_update_query.htm#a7c1b4eaa45048ec8a3f6f7d4223f5ace">set</a>(<span class="stringliteral">&quot;b&quot;</span>, 222)</div><div class="line">      .<a class="code" href="class_update_query.htm#aa685f7d12dec7214a783be4289b39f4c">exec</a>();</div></div><!-- fragment --> 
</div>
</div>
<a id="ab83ea43c6e98bd5534d9fa8ba0e5fe1b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab83ea43c6e98bd5534d9fa8ba0e5fe1b">&#9670;&nbsp;</a></span>set() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_update_query.htm">UpdateQuery</a>&amp; UpdateQuery::set </td>
          <td>(</td>
          <td class="paramtype">const QVariantMap &amp;&#160;</td>
          <td class="paramname"><em>map</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Sets table fields to values from <em>map</em> </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">map</td><td>Values map. Map key is field name, map value is field value.</td></tr>
  </table>
  </dd>
</dl>
<p>The method returns an <a class="el" href="class_update_query.htm" title="QSqlQuery wrapper for UPDATE ... SET ... WHERE ... query execution. ">UpdateQuery</a> reference so its calls can be chained.</p>
<div class="fragment"><div class="line"><span class="comment">//UPDATE table SET a=111, b=222</span></div><div class="line">t.<a class="code" href="class_database.htm#a2d8dad3df4134306749582216bd437e0">update</a>(<span class="stringliteral">&quot;table&quot;</span>)</div><div class="line">      .<a class="code" href="class_update_query.htm#a7c1b4eaa45048ec8a3f6f7d4223f5ace">set</a>(QVariantMap{ {<span class="stringliteral">&quot;a&quot;</span>, 111}, {<span class="stringliteral">&quot;b&quot;</span>, 222} })</div><div class="line">      .<a class="code" href="class_update_query.htm#aa685f7d12dec7214a783be4289b39f4c">exec</a>();</div></div><!-- fragment --> 
</div>
</div>
<a id="abb4c7b7502599a78699e3a1f4cb4cbda"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abb4c7b7502599a78699e3a1f4cb4cbda">&#9670;&nbsp;</a></span>where() <span class="overload">[1/3]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_non_query_result.htm">NonQueryResult</a> UpdateQuery::where </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>expr</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Executes update query with <em>expr</em> condition. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">expr</td><td>WHERE condition</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line"><span class="comment">//UPDATE table SET a=111, b=222 WHERE a=1 AND b=2</span></div><div class="line">t.<a class="code" href="class_database.htm#a2d8dad3df4134306749582216bd437e0">update</a>(<span class="stringliteral">&quot;table&quot;</span>)</div><div class="line">      .<a class="code" href="class_update_query.htm#a7c1b4eaa45048ec8a3f6f7d4223f5ace">set</a>(QVariantMap{ {<span class="stringliteral">&quot;a&quot;</span>, 111}, {<span class="stringliteral">&quot;b&quot;</span>, 222} })</div><div class="line">      .<a class="code" href="class_update_query.htm#abb4c7b7502599a78699e3a1f4cb4cbda">where</a>(<span class="stringliteral">&quot;a=1 AND b=2&quot;</span>);</div></div><!-- fragment --> 
</div>
</div>
<a id="a666356b92d38bed265199b57bcd8c0e7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a666356b92d38bed265199b57bcd8c0e7">&#9670;&nbsp;</a></span>where() <span class="overload">[2/3]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_non_query_result.htm">NonQueryResult</a> UpdateQuery::where </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>expr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QVariant &amp;&#160;</td>
          <td class="paramname"><em>last</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Executes update query with <em>expr</em> condition and <em>last</em> parameter binding. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">expr</td><td>WHERE condition </td></tr>
    <tr><td class="paramname">last</td><td>Parameter to bind on WHERE expression</td></tr>
  </table>
  </dd>
</dl>
<p>The method supports variable count of QVariant parameters. Parameters are bound with <em>QSqlQuery::addBindValue</em>. </p><div class="fragment"><div class="line"><span class="comment">//UPDATE table SET a=111, b=222 WHERE a=1 AND b=2</span></div><div class="line">t.<a class="code" href="class_database.htm#a2d8dad3df4134306749582216bd437e0">update</a>(<span class="stringliteral">&quot;table&quot;</span>)</div><div class="line">      .<a class="code" href="class_update_query.htm#a7c1b4eaa45048ec8a3f6f7d4223f5ace">set</a>(QVariantMap{ {<span class="stringliteral">&quot;a&quot;</span>, 111}, {<span class="stringliteral">&quot;b&quot;</span>, 222} })</div><div class="line">      .<a class="code" href="class_update_query.htm#abb4c7b7502599a78699e3a1f4cb4cbda">where</a>(<span class="stringliteral">&quot;a=? AND b=?&quot;</span>, 1, 2);</div></div><!-- fragment --> 
</div>
</div>
<a id="a423087092ef6c17c5d97e6a268f85775"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a423087092ef6c17c5d97e6a268f85775">&#9670;&nbsp;</a></span>where() <span class="overload">[3/3]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename... Rest&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_non_query_result.htm">NonQueryResult</a> UpdateQuery::where </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>expr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QVariant &amp;&#160;</td>
          <td class="paramname"><em>first</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const Rest &amp;...&#160;</td>
          <td class="paramname"><em>rest</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>EasyQtSql/<a class="el" href="_easy_qt_sql___update_query_8h_source.htm">EasyQtSql_UpdateQuery.h</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="class_update_query.htm">UpdateQuery</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
